/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.VisibleGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.main.MainGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations.Showable;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.Frame;

/**
 *
 * @author Admin
 */
public class FrameGenerator implements Generator,Generatable {

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Frame)
            return true;
        else return false;
    }

     @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generateUniqueAttributes(sb, (Frame)o,recursionLevel);
        VisibleGenerator.generateVisibleAttribute(sb, recursionLevel);
        VisibleGenerator.generateVisibleVar(sb, (Showable)o, recursionLevel);
        Frame frame = (Frame)o;
        this.generateCanvas(sb,frame.getCanvas(),recursionLevel);
        this.generateEnd(sb);
    }

    @Override
    public void generateStart(StringBuilder sb){
        sb.append("Frame{\n");
    }
    @Override
    public void generateEnd(StringBuilder sb){
        EndGenerator.generateEnd(sb);
    }
    @Override
    public void generateUniqueAttributes(StringBuilder sb,Object o,int recursionLevel){
        Frame f = (Frame)o;
        sb.append("title:\""+f.getTitle()+"\";\n");
        sb.append("height:"+f.getHeight()+";\n");
        sb.append("width:"+f.getWidth()+";\n");
        sb.append("resizable:"+f.getResizable()+";\n");
        sb.append("screenx:"+f.getHScreenPosition()+";\n");
        sb.append("screeny:"+f.getVScreenPosition()+";\n");
        
    }
    public void generateCanvas(StringBuilder sb,Object f,int recursionLevel){
        sb.append("content:\n");
        recursionLevel++;
        MainGenerator.generateNext(f, recursionLevel,f);
    }

   
}
